function counter(initValue, step) {
    function C(initValue, step) {
        this.initValue = initValue
        this.step = step
    }
    C.prototype.add = function() {
        this.initValue += this.step
        console.log(this.initValue)
       
    }
    C.prototype.sub = function() {
        this.initValue -= this.step
        console.log(this.initValue)
    }
    return new C(initValue, step)
}
const c = counter(4, 2)
c.add()
c.sub()
c.add()
c.add()